package com.aizhixin.lab.task.service;

import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.aizhixin.lab.common.core.DataValidity;
import com.aizhixin.lab.task.domain.TaskQuestionChoiceDomain;
import com.aizhixin.lab.task.entity.ReleaseQuestionChoice;
import com.aizhixin.lab.task.entity.TaskQuestionChoice;
import com.aizhixin.lab.task.repository.ReleaseQuestionChoiceRepository;
import com.aizhixin.lab.task.repository.TaskQuestionChoiceRepository;

@Slf4j
@Service
@Transactional
public class ReleaseTaskQuestionChoiceService {
	@Autowired
	private ReleaseQuestionChoiceRepository releaseQuestionChoiceRepository;


	
	public void save(ReleaseQuestionChoice choice) {
		releaseQuestionChoiceRepository.save(choice);
	}
	
	public void saveList(List<ReleaseQuestionChoice> choices) {
		releaseQuestionChoiceRepository.save(choices);
	}
	
    public List<ReleaseQuestionChoice> getChoiceList(String releaseQuestionId){
    	return releaseQuestionChoiceRepository.findAllByDeleteFlagAndReleaseQuestionIdOrderByOptionAsc(DataValidity.VALID.getState(), releaseQuestionId);
    }
    
    public List<ReleaseQuestionChoice> getChoiceList(List<String> releaseQuestionIds){
    	return releaseQuestionChoiceRepository.findAllByDeleteFlagAndReleaseQuestionIdIn(DataValidity.VALID.getState(), releaseQuestionIds);
    }

	 public void delChoiceList(List<ReleaseQuestionChoice> choiceList) {
		 releaseQuestionChoiceRepository.delete(choiceList);
	 }
	 
	 
}
